#include "info_model.h"

namespace info_model
{
	bool info_model::add_object(object_t obj)
	{
		boost::mutex::scoped_lock lock(object_mutex);
		object_map_t::iterator it = object_map.find(obj->object_id());

		if ( it == object_map.end()) {
			object_map.insert(std::make_pair(obj->object_id(), obj));
			return true;
		}

		return false;
	}

	void info_model::remove(object_type type)
	{
		boost::mutex::scoped_lock lock(object_mutex);
		object_map.erase(type);
	}

	object_t info_model::find(object_type type)
	{
		object_map_t::iterator it = object_map.find(type);
		if ( it != object_map.end()) {
			return it->second;
		}

		return object_t();
	}
}